package com.javainterface.controller;

import com.javainterface.service.UserCentorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/userCenter")
public class UserCentorController {
    @Autowired
    UserCentorService userCentorService;

    public String getToken() {
        return userCentorService.getToken();
    }

    @PostMapping("/passwordUpdate")
    @ResponseBody
    public String passwordUpdate(String username, String oldPassword, String newPassword) {
        return userCentorService.passwordUpdate(getToken(), username, oldPassword, newPassword);
    }

    @PostMapping("/passwordReset")
    @ResponseBody
    public String passwordReset(String username, String newPassword) {
        return userCentorService.passwordReset(getToken(), username, newPassword);
    }


}
